package com.tg.paw.ums.controller;

import cn.hutool.core.date.DateUtil;
import com.tg.paw.common.component.UserUtil;
import com.tg.paw.common.constant.CommonConstant;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

/**
 * DemoController
 *
 * @author Rubble
 * @date 2020/6/12
 */
@RestController
@RequestMapping("/demo")
public class DemoController {

    @Autowired
    private RedisTemplate<String,Object> redisTemplate;

    @Autowired
    private StringRedisTemplate stringRedisTemplate;



    @GetMapping("/hello")
    public String hello(){
        String username = UserUtil.getLoginUsername();
        return "hello "+ username+" "+DateUtil.now() ;
    }

    @GetMapping("/userInfo")
    public String userInfo(HttpServletRequest request){
        String username = request.getHeader(CommonConstant.Authorization_UserName);
        String token = request.getHeader(CommonConstant.ACCESS_TOKEN);
        return username +" token: "+token;
    }
}
